home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Mac OS USB DDK / Examples / PrinterClassDriver / SafeNameRegistry.cp < prev    next >
Encoding:
Text File  |  1999-02-10  |  21.5 KB  |  678 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SafeNameRegistry.cp
  3.  
  4.     Contains:    Stub routines for name registry calls
  5.  
  6.     Think of the Name Registry as a database used by System software 
  7.     to keep track of hardware and other settings. Its up to the 
  8.     indivdual software (called expert software) to insert and remove 
  9.     entries from the Name Registry. The information contained inside 
  10.     the entries can be whatever the expert software deems important.
  11.  
  12.     The Name Registry is only available on PCI based Macs. The Name
  13.     Registry routines reside in a PPC shared library (there isn't a
  14.     68K version), hence the need for these stub routines. When we build
  15.     fat drivers there is a chance on a PPC of running the 68K version
  16.     of the driver. Therefore we needed a way of calling into the Name
  17.     Registry shared library from 68K code. These routines will load the
  18.     Name Registry library and create procptrs for the needed calls. The
  19.     same stub calls will work on PPC and 68K
  20.  
  21.  
  22.  
  23.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  24.  
  25.     Change History:
  26.  
  27.         10 Jun 98    gp        Use a local variable to store the name registry routine address
  28.                             before assigning it to our global area
  29.         9  Jun 98     gp        Use our connection id when looking for routine addresses
  30.                             Use DisposeRoutineDescriptorTrap when disposing of the
  31.         4  May 98     gp        Replaced Find_Symbol with FindAddress
  32.         25 Mar 98     gp        Added calls to create and remove name registry proc ptrs
  33.         18 Mar 98     gp        Created
  34.  
  35.     To Do:
  36. */
  37.  
  38. #ifndef __Chooser__
  39. #include "Chooser.h"
  40. #endif
  41.  
  42. #ifndef __CODEFRAGMENTS__
  43. #include <CodeFragments.h>
  44. #endif
  45.  
  46. #ifndef __MIXEDMODE__
  47. #include <MixedMode.h>
  48. #endif
  49.  
  50. #ifndef __GESTALT__
  51. #include <Gestalt.h>
  52. #endif
  53.  
  54. #ifndef __ERRORS__
  55. #include <Errors.h>
  56. #endif
  57.  
  58. #ifndef __DIALOGS__
  59. #include <Dialogs.h>
  60. #endif
  61.  
  62. #ifndef __SafeNameRegistry__
  63. #include "SafeNameRegistry.h"
  64. #endif
  65.  
  66. /******************************************************************************
  67.     Prototypes
  68.  ******************************************************************************/
  69.  
  70. // prototypes used to find address of routine in name registry library
  71. OSErr FindAddress(Ptr* pSymAddr, Str255 pSymName, ProcInfoType pProcInfo);
  72. pascal OSErr GetSystemArchitecture(OSType *archType);
  73.  
  74. /******************************************************************************
  75.     Typedefs
  76.  ******************************************************************************/
  77.  
  78. // proc typedefs for calling routines in the name registry library
  79. typedef pascal OSStatus (*RegistryEntryIDInitProcPtr) ( RegEntryID* id );
  80. typedef pascal OSStatus (*RegistryCStrEntryLookupProcPtr) ( RegEntryID* searchPointID, 
  81.             RegCStrPathName* pathName, RegEntryID*foundEntry );
  82. typedef pascal OSStatus (*RegistryEntryIterateCreateProcPtr) ( RegEntryIter* cookie );
  83. typedef pascal OSStatus (*RegistryEntryIterateDisposeProcPtr) ( RegEntryIter* cookie );
  84. typedef pascal OSStatus (*RegistryEntryIterateSetProcPtr) ( RegEntryIter* cookie, RegEntryID *startEntryID );
  85. typedef pascal OSStatus (*RegistryEntryIterateProcPtr) ( RegEntryIter *cookie, 
  86.             RegEntryIterationOp relationship, RegEntryID *foundEntry, Boolean *done );
  87. typedef pascal OSStatus (*RegistryEntryIDDisposeProcPtr) ( RegEntryID* id );
  88. typedef pascal OSStatus (*RegistryPropertyGetProcPtr) ( RegEntryID *entryID, 
  89.             RegPropertyName *propertyName, void *propertyValue, RegPropertyValueSize *propertySize );
  90.  
  91. /******************************************************************************
  92.     Constants
  93.  ******************************************************************************/
  94.  
  95. #define    kNoNameRegistryAlert        3000
  96.  
  97. // stack descriptors used in the name registry stub calls to pass params
  98. // to the proper routine in the name registry shared library
  99.  
  100. enum {
  101.     kRegistryEntryIDInitProcInfo = kPascalStackBased
  102.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  103.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  104. };
  105. enum {
  106.     kRegistryCStrEntryLookupProcInfo = kPascalStackBased
  107.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  108.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  109.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegCStrPathName*)))
  110.     | STACK_ROUTINE_PARAMETER( 3, SIZE_CODE(sizeof( RegEntryID*)))
  111. };
  112. enum {
  113.     kRegistryEntryIterateCreateProcInfo = kPascalStackBased
  114.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  115.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  116. };
  117. enum {
  118.     kRegistryEntryIterateDisposeProcInfo = kPascalStackBased
  119.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  120.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  121. };
  122. enum {
  123.     kRegistryEntryIterateSetProcInfo = kPascalStackBased
  124.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  125.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  126.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegEntryID*)))
  127. };
  128. enum {
  129.     kRegistryEntryIterateProcInfo = kPascalStackBased
  130.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  131.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  132.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegEntryIterationOp)))
  133.     | STACK_ROUTINE_PARAMETER( 3, SIZE_CODE(sizeof( RegEntryID*)))
  134.     | STACK_ROUTINE_PARAMETER( 4, SIZE_CODE(sizeof( Boolean*)))
  135. };
  136. enum {
  137.     kRegistryEntryIDDisposeProcInfo = kPascalStackBased
  138.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  139.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  140. };
  141. enum {
  142.     kRegistryPropertyGetProcInfo = kPascalStackBased
  143.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  144.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  145.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegPropertyName*)))
  146.     | STACK_ROUTINE_PARAMETER( 3, SIZE_CODE(sizeof( void*)))
  147.     | STACK_ROUTINE_PARAMETER( 4, SIZE_CODE(sizeof( RegPropertyValueSize*)))
  148. };
  149.  
  150. /*-----------------------------------------------------------------------------*
  151.  
  152.     NameRegistryInstalled
  153.     
  154.     Desc:        Test to see if the name registry exists on this machine
  155.  
  156.     In:            None
  157.  
  158.     Out:        True if name registry exists else false
  159.     
  160.     History:
  161.  
  162.     18 Mar 98    gp        Added.
  163.     
  164. *-----------------------------------------------------------------------------*/
  165. Boolean    NameRegistryInstalled( void )
  166. {
  167.     OSErr    err=noErr;        // result from gestalt call
  168.     long    result;
  169.     USBGlobalsHandle    gGlobals=nil;        // our global data area
  170.  
  171.     gGlobals = GetGlobalStorage();
  172.  
  173.     // if not our first time then return previous result
  174.     if( (**gGlobals).checkedForNameRegistry == true )
  175.         return (**gGlobals).hasNameRegistry;
  176.     else {
  177.  
  178.     // check to see if name registry exists
  179.         err = Gestalt(gestaltNameRegistryVersion, &result);
  180.         if( err == noErr )
  181.             (**gGlobals).hasNameRegistry = true;
  182.         else {
  183.             (**gGlobals).hasNameRegistry = false;
  184.     // put up alert if it isn't installed
  185.             StopAlert(kNoNameRegistryAlert, nil);
  186.         }
  187.         (**gGlobals).checkedForNameRegistry=true;
  188.     }
  189.     return (**gGlobals).hasNameRegistry;
  190. }
  191.  
  192. /*-----------------------------------------------------------------------------*
  193.  
  194.     SafeRegistryEntryIDInit
  195.     
  196.     Desc:        Stub code for name registry routine 'RegistryEntryIDInit'
  197.  
  198.     In:            id - pointer to a RegEntryID to initialize
  199.  
  200.     Out:        returns any errors which may have occur
  201.     
  202.     History:
  203.  
  204.     18 Mar 98    gp        Added.
  205.     
  206. *-----------------------------------------------------------------------------*/
  207.  
  208. OSStatus SafeRegistryEntryIDInit(RegEntryID *id)
  209. {
  210.     OSStatus    anErr=-1;                // return value
  211.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  212.  
  213.     gGlobals = GetGlobalStorage();
  214.  
  215.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIDInitAddr != (Ptr) nil )
  216.         anErr = ((RegistryEntryIDInitProcPtr) (**gGlobals).RegistryEntryIDInitAddr) (id);
  217.     return anErr;
  218. }
  219.  
  220. /*-----------------------------------------------------------------------------*
  221.  
  222.     SafeRegistryCStrEntryLookup
  223.     
  224.     Desc:        Stub code for name registry routine 'RegistryCStrEntryLookup'
  225.  
  226.     In:            searchPointID - the RegEntryID to start searching from
  227.                 pathName - the cstring path of the entry to find
  228.                 foundEntry - where to store the found entry
  229.  
  230.     Out:        foundEntry - the RegEntryID of any found entry
  231.                 returns any errors which may have occur
  232.     
  233.     History:
  234.  
  235.     18 Mar 98    gp        Added.
  236.     
  237. *-----------------------------------------------------------------------------*/
  238. OSStatus SafeRegistryCStrEntryLookup( RegEntryID *searchPointID, RegCStrPathName *pathName, RegEntryID *foundEntry)
  239. {
  240.     OSStatus    anErr=-1;                // return value
  241.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  242.  
  243.     gGlobals = GetGlobalStorage();
  244.     
  245.     // now call it
  246.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryCStrEntryLookupAddr != (Ptr) nil )
  247.         anErr = ((RegistryCStrEntryLookupProcPtr) (**gGlobals).RegistryCStrEntryLookupAddr) (searchPointID, pathName, foundEntry);
  248.     return anErr;
  249. }
  250.  
  251. /*-----------------------------------------------------------------------------*
  252.  
  253.     SafeRegistryEntryIterateCreate
  254.     
  255.     Desc:        Stub code for name registry routine 'RegistryEntryIterateCreate'
  256.  
  257.     In:            id - pointer to a RegEntryIter to initialize
  258.  
  259.     Out:        returns any errors which may have occur
  260.     
  261.     History:
  262.  
  263.     18 Mar 98    gp        Added.
  264.     
  265. *-----------------------------------------------------------------------------*/
  266. OSStatus SafeRegistryEntryIterateCreate(RegEntryIter *cookie)
  267. {
  268.     OSStatus    anErr=-1;                // return value
  269.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  270.  
  271.     gGlobals = GetGlobalStorage();
  272.  
  273.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateCreateAddr != (Ptr) nil )
  274.         anErr = ((RegistryEntryIterateCreateProcPtr) (**gGlobals).RegistryEntryIterateCreateAddr) (cookie);
  275.     return anErr;
  276. }
  277.  
  278. /*-----------------------------------------------------------------------------*
  279.  
  280.     SafeRegistryEntryIterateDispose
  281.     
  282.     Desc:        Stub code for name registry routine 'RegistryEntryIterateDispose'
  283.  
  284.     In:            cookie - iterator to dispose
  285.  
  286.     Out:        returns any errors which may have occur
  287.     
  288.     History:
  289.  
  290.     18 Mar 98    gp        Added.
  291.     
  292. *-----------------------------------------------------------------------------*/
  293. OSStatus SafeRegistryEntryIterateDispose(RegEntryIter *cookie)
  294. {
  295.     OSStatus    anErr=-1;                // return value
  296.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  297.  
  298.     gGlobals = GetGlobalStorage();
  299.  
  300.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateDisposeAddr != (Ptr) nil )
  301.         anErr = ((RegistryEntryIterateDisposeProcPtr) (**gGlobals).RegistryEntryIterateDisposeAddr) (cookie);
  302.     return anErr;
  303. }
  304.  
  305. /*-----------------------------------------------------------------------------*
  306.  
  307.     SafeRegistryEntryIterateSet
  308.     
  309.     Desc:        Stub code for name registry routine 'RegistryEntryIterateSet'
  310.  
  311.     In:            cookie - pointer to iterator to set
  312.                 startEntryID - name registry entry to start iterating from
  313.  
  314.     Out:        returns any errors which may have occur
  315.     
  316.     History:
  317.  
  318.     18 Mar 98    gp        Added.
  319.     
  320. *-----------------------------------------------------------------------------*/
  321. OSStatus SafeRegistryEntryIterateSet(RegEntryIter *cookie, RegEntryID *startEntryID)
  322. {
  323.     OSStatus    anErr=-1;                // return value
  324.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  325.  
  326.     gGlobals = GetGlobalStorage();
  327.  
  328.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateSetAddr != (Ptr) nil )
  329.         anErr = ((RegistryEntryIterateSetProcPtr) (**gGlobals).RegistryEntryIterateSetAddr) (cookie, startEntryID);
  330.     return anErr;
  331. }
  332.  
  333. /*-----------------------------------------------------------------------------*
  334.  
  335.     SafeRegistryEntryIterate
  336.     
  337.     Desc:        Stub code for name registry routine 'RegistryEntryIterate'
  338.  
  339.     In:            cookie - iterator to use
  340.                 relationship - direction to iterate
  341.                 foundEntry - where to store next name entry found
  342.                 done - tells if we're done with iteration
  343.  
  344.     Out:        foundEntry - RegEntryID of name entry found
  345.                 done - true if no more entries found
  346.                 returns any errors which may have occur
  347.     
  348.     History:
  349.  
  350.     18 Mar 98    gp        Added.
  351.     
  352. *-----------------------------------------------------------------------------*/
  353. OSStatus SafeRegistryEntryIterate(RegEntryIter *cookie, RegEntryIterationOp relationship, 
  354.         RegEntryID *foundEntry, Boolean *done)
  355. {
  356.     OSStatus    anErr=-1;                // return value
  357.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  358.  
  359.     gGlobals = GetGlobalStorage();
  360.  
  361.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateAddr != (Ptr) nil )
  362.         anErr = ((RegistryEntryIterateProcPtr) (**gGlobals).RegistryEntryIterateAddr) (cookie, relationship, foundEntry, done);
  363.     return anErr;
  364. }
  365.  
  366. /*-----------------------------------------------------------------------------*
  367.  
  368.     SafeRegistryEntryIDDispose
  369.     
  370.     Desc:        Stub code for name registry routine 'RegistryEntryIDDispose'
  371.  
  372.     In:            id - RegEntryID to dispose
  373.  
  374.     Out:        returns any errors which may have occur
  375.     
  376.     History:
  377.  
  378.     18 Mar 98    gp        Added.
  379.     
  380. *-----------------------------------------------------------------------------*/
  381. OSStatus SafeRegistryEntryIDDispose(RegEntryID *id)
  382. {
  383.     OSStatus    anErr=-1;                // return value
  384.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  385.  
  386.     gGlobals = GetGlobalStorage();
  387.  
  388.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIDDisposeAddr != (Ptr) nil )
  389.         anErr = ((RegistryEntryIDDisposeProcPtr) (**gGlobals).RegistryEntryIDDisposeAddr) (id);
  390.     return anErr;
  391. }
  392.  
  393. /*-----------------------------------------------------------------------------*
  394.  
  395.     SafeRegistryPropertyGet
  396.     
  397.     Desc:        Stub code for name registry routine 'RegistryPropertyGet'
  398.  
  399.     In:            entryID - RegEntryID value that identifies a name entry
  400.                 propertyName - name of the property
  401.                 propertyValue - buffer to hold the property
  402.                 propertySize - size of the property buffer
  403.  
  404.     Out:        propertySize - size of the property retrieved
  405.                 returns any errors which may have occur
  406.     
  407.     History:
  408.  
  409.     18 Mar 98    gp        Added.
  410.     
  411. *-----------------------------------------------------------------------------*/
  412. OSStatus SafeRegistryPropertyGet( RegEntryID *entryID, RegPropertyName *propertyName, 
  413.         void *propertyValue, RegPropertyValueSize *propertySize)
  414. {
  415.     OSStatus    anErr=-1;                // return value
  416.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  417.  
  418.     gGlobals = GetGlobalStorage();
  419.  
  420.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryPropertyGetAddr != (Ptr) nil )
  421.         anErr = ((RegistryPropertyGetProcPtr) (**gGlobals).RegistryPropertyGetAddr) (entryID, propertyName, propertyValue, propertySize);
  422.     return anErr;
  423. }
  424.  
  425. /*-----------------------------------------------------------------------------*
  426.  
  427.     GetSystemArchitecture
  428.     
  429.     Desc:        Taken from 
  430.                 DTS Technote 1077 "Calling CFM Code from Classic 68K Code".
  431.                 Returns architect of current cpu during runtime.
  432.  
  433.  
  434.     In:            archType - address of variable to hold architect type
  435.  
  436.     Out:        archType - returns architect of current cpu pointed by this variable
  437.                 Also returns any errors
  438.     
  439.     History:
  440.  
  441.     18 Mar 98    gp        Added.
  442.     
  443. *-----------------------------------------------------------------------------*/
  444.  
  445. pascal OSErr GetSystemArchitecture(OSType *archType)
  446. {
  447.     long sSysArchitecture = 0; // static so we only Gestalt once.
  448.     OSErr tOSErr = noErr;
  449.     
  450.     *archType = kAnyCFragArch;   // assume wild architecture
  451.     
  452.     // If we don't know the system architecture yet...
  453.     if (sSysArchitecture == 0)
  454.         // ...Ask Gestalt what kind of machine we are running on.
  455.         tOSErr = Gestalt(gestaltSysArchitecture, &sSysArchitecture);
  456.     
  457.     if (tOSErr == noErr) // if no errors
  458.     {
  459.         if (sSysArchitecture == gestalt68k)   // 68k?
  460.              *archType = kMotorola68KCFragArch;   
  461.         else if (sSysArchitecture == gestaltPowerPC) // PPC?
  462.              *archType = kPowerPCCFragArch;       
  463.         else
  464.              tOSErr = gestaltUnknownErr;  // who knows what might be next?
  465.     }
  466.     return tOSErr;
  467. }
  468.  
  469. /*-----------------------------------------------------------------------------*
  470.  
  471.     FindAddress
  472.     
  473.     Desc:        Taken from 
  474.                 DTS Technote 1077 "Calling CFM Code from Classic 68K Code".
  475.                 Returns the address of a routine in a shared library
  476.  
  477.     In:            pSymAddr - address of variable to hold returned address
  478.                 pSymName - a pstring of the name of the routine
  479.                 pProcInfo - stack descriptor for the routine
  480.  
  481.     Out:        pSymAddr - the address of the routine pointed by this variable
  482.                 Also returns any errors
  483.     
  484.     History:
  485.  
  486.     10 Jun 98    gp        Init the address ptr passed in before using it
  487.     9  Jun 98    gp        Use our connection id to the name registry instead of
  488.                         opening it every time
  489.     18 Mar 98    gp        Added.
  490.     
  491. *-----------------------------------------------------------------------------*/
  492.  
  493. OSErr FindAddress(Ptr* pSymAddr, Str255 pSymName, ProcInfoType pProcInfo)
  494. {
  495.     CFragConnectionID sCID = 0;
  496.     OSType sArchType = kAnyCFragArch;
  497.     OSErr sOSErr = noErr;
  498.     USBGlobalsHandle    gGlobals=nil;        // our global data area
  499.  
  500.     Str255 errMessage;
  501.     Ptr mainAddr;
  502.     CFragSymbolClass symClass;
  503.           ISAType tISAType;
  504.     
  505.     *pSymAddr = (Ptr) kUnresolvedCFragSymbolAddress;
  506.  
  507.     if( NameRegistryInstalled() == false )
  508.         return -1;            // return general error - gp
  509.     
  510.     gGlobals = GetGlobalStorage();
  511.  
  512.     if (sArchType == kAnyCFragArch)  // if architecture is undefined...
  513.     {
  514.         sCID = 0;     // ...force (re)connect to library
  515.         sOSErr = GetSystemArchitecture(&sArchType); // determine architecture
  516.         if (sOSErr != noErr)
  517.              return sOSErr; // OOPS!
  518.     }
  519.     
  520.     if (sArchType == kMotorola68KCFragArch) // ...for CFM68K
  521.           tISAType = kM68kISA | kCFM68kRTA;
  522.     else if (sArchType == kPowerPCCFragArch)  // ...for PPC CFM
  523.           tISAType = kPowerPCISA | kPowerPCRTA;
  524.     else
  525.         sOSErr = gestaltUnknownErr; // who knows what might be next?
  526.     
  527.      sCID = (**gGlobals).sCID;
  528.     if (sCID == 0) // If we haven't connected to the library yet...
  529.     {
  530.         // NOTE: The library name is hard coded here.
  531.         // I try to isolate the glue code, one file per library.
  532.         // I have had developers pass in the Library name to allow
  533.         // plug-in type support. Additional code has to be added to
  534.         // each entry points glue routine to support multiple or
  535.         // switching connection IDs.
  536.         sOSErr = GetSharedLibrary("\pNameRegistryLib", sArchType, kLoadCFrag,
  537.                    &sCID, &mainAddr, errMessage);
  538.         if (sOSErr != noErr)
  539.              return sOSErr; // OOPS!
  540.          (**gGlobals).sCID = sCID;            // save connection id
  541.     }
  542.     
  543.     // If we haven't looked up this symbol yet...
  544.     if ((Ptr) *pSymAddr == (Ptr) kUnresolvedCFragSymbolAddress)    
  545.     {
  546.         // ...look it up now
  547.         sOSErr = FindSymbol(sCID,pSymName,pSymAddr,&symClass);
  548.         if (sOSErr != noErr) {// in case of error...
  549.          // ...clear the procedure pointer
  550.              *pSymAddr = (Ptr) kUnresolvedCFragSymbolAddress;
  551.         }
  552.         #if !GENERATINGCFM // if this is classic 68k code...
  553.          *pSymAddr = (Ptr)NewRoutineDescriptorTrap((ProcPtr) *pSymAddr,
  554.                       pProcInfo, tISAType);  // ...create a routine descriptor...
  555.         #endif
  556.     }
  557.     return sOSErr;
  558. }
  559.  
  560. /*-----------------------------------------------------------------------------*
  561.  
  562.     InitNameRegistryPtrs
  563.     
  564.     Desc:        Create all the proc ptrs to Name Registry calls we will
  565.                 need
  566.  
  567.     In:            None
  568.  
  569.     Out:        None
  570.     
  571.     History:
  572.  
  573.     10 Jun 98    gp        Use a local variable to store the routine address
  574.     9  Jun 98    gp        Init our connection id to the name registry
  575.     25 Mar 98    gp        Created
  576.     
  577. *-----------------------------------------------------------------------------*/
  578. void    InitNameRegistryPtrs( void )
  579. {
  580.     USBGlobalsHandle    gGlobals = nil;        // our global data area
  581.     Ptr                    address = nil;
  582.  
  583.     gGlobals = GetGlobalStorage();
  584.  
  585.     if( gGlobals != nil && NameRegistryInstalled() == true) {
  586.         (**gGlobals).sCID = 0;
  587.  
  588.         FindAddress( (Ptr*) &address, 
  589.                 "\pRegistryEntryIDInit", kRegistryEntryIDInitProcInfo );
  590.         (**gGlobals).RegistryEntryIDInitAddr = (ProcPtr) address;
  591.  
  592.         FindAddress( (Ptr*) &address, 
  593.                 "\pRegistryCStrEntryLookup", kRegistryCStrEntryLookupProcInfo );
  594.         (**gGlobals).RegistryCStrEntryLookupAddr = (ProcPtr) address;
  595.  
  596.         FindAddress( (Ptr*) &address, 
  597.                 "\pRegistryEntryIterateCreate", kRegistryEntryIterateCreateProcInfo );
  598.         (**gGlobals).RegistryEntryIterateCreateAddr = (ProcPtr) address;
  599.  
  600.         FindAddress( (Ptr*) &address, 
  601.                 "\pRegistryEntryIterateDispose", kRegistryEntryIterateDisposeProcInfo );
  602.         (**gGlobals).RegistryEntryIterateDisposeAddr = (ProcPtr) address;
  603.  
  604.         FindAddress( (Ptr*) &address, 
  605.                 "\pRegistryEntryIterateSet", kRegistryEntryIterateSetProcInfo );
  606.         (**gGlobals).RegistryEntryIterateSetAddr = (ProcPtr) address;
  607.  
  608.         FindAddress( (Ptr*) &address, 
  609.                 "\pRegistryEntryIterate", kRegistryEntryIterateProcInfo );
  610.         (**gGlobals).RegistryEntryIterateAddr = (ProcPtr) address;
  611.  
  612.         FindAddress( (Ptr*) &address, 
  613.                 "\pRegistryEntryIDDispose", kRegistryEntryIDDisposeProcInfo );
  614.         (**gGlobals).RegistryEntryIDDisposeAddr = (ProcPtr) address;
  615.  
  616.         FindAddress( (Ptr*) &address, 
  617.                 "\pRegistryPropertyGet", kRegistryPropertyGetProcInfo );
  618.         (**gGlobals).RegistryPropertyGetAddr = (ProcPtr) address;
  619.     }
  620. }
  621.  
  622. /*-----------------------------------------------------------------------------*
  623.  
  624.     RemoveNameRegistryPtrs
  625.     
  626.     Desc:        Remove all the proc ptrs we created for Name Registry calls
  627.  
  628.     In:            None
  629.  
  630.     Out:        None
  631.     
  632.     History:
  633.  
  634.     9  Jun 98    gp        Close our connection id to the name registry
  635.                         Use DisposeRoutineDescriptorTrap when disposing of the
  636.                         name registry routine descriptors
  637.     25 Mar 98    gp        Created
  638.     
  639. *-----------------------------------------------------------------------------*/
  640. void    RemoveNameRegistryPtrs(void)
  641. {
  642.     USBGlobalsHandle    gGlobals=nil;        // our global data area
  643.     CFragConnectionID sCID;
  644.  
  645.     
  646.     gGlobals = GetGlobalStorage();
  647.     if( gGlobals != nil ) {
  648.         // dispose of proc ptrs
  649.         
  650.         if( (**gGlobals).RegistryEntryIDInitAddr != nil )
  651.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIDInitAddr);
  652.         
  653.         if( (**gGlobals).RegistryCStrEntryLookupAddr != nil )
  654.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryCStrEntryLookupAddr);
  655.         
  656.         if( (**gGlobals).RegistryEntryIterateCreateAddr != nil )
  657.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateCreateAddr);
  658.         
  659.         if( (**gGlobals).RegistryEntryIterateDisposeAddr != nil )
  660.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateDisposeAddr);
  661.         
  662.         if( (**gGlobals).RegistryEntryIterateSetAddr != nil )
  663.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateSetAddr);
  664.         
  665.         if( (**gGlobals).RegistryEntryIterateAddr != nil )
  666.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateAddr);
  667.         
  668.         if( (**gGlobals).RegistryEntryIDDisposeAddr != nil )
  669.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIDDisposeAddr);
  670.         
  671.         if( (**gGlobals).RegistryPropertyGetAddr != nil )
  672.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryPropertyGetAddr);
  673.  
  674.         sCID = (**gGlobals).sCID;
  675.         CloseConnection( &sCID );
  676.     }
  677. }
  678.